<br>
<form class="layui-form">
    <div class="layui-form-item">
        <input type="hidden" name="id" value="{$id}" />
       <p style="margin-left: 50px;">当前版本是<input style="width: 40px;display: inline-block;border: none;" type="text" name="versionNumber" id="number" class="layui-input" value="{$versionInfo}">版本</p>
       <p style="margin-left: 50px;margin-bottom: 10px;">请确认你要切换至当前版本么？</p>
    </div>
    <div class="layui-form-item">
        <div style="margin-left: 50px;" class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="switch">确认</button>
        </div>
    </div>
</form>
<script>
    layui.use('form', function(){
        var form = layui.form,
            $ = layui.jquery;
        form.render();
        //监听提交
        form.on('submit(switch)', function(data){
            var versionInfo = data.field;
            var url =  "{U('Version/switchVersion')}";
            $.post(url,versionInfo,function(data){
                if(data.status == 'error'){
                    layer.msg(data.msg,{
                        icon: 2 //失败的表情
                    });
                }else if(data.status =='success'){
                    layer.msg(data.msg,{
                        icon: 1,//成功的表情
                        time: 1000
                    },function(){
                        location.reload();
                    });//失败的表情
                }
            })
            return false;//阻止表单跳转
        });
    });
</script>